<?php

namespace app\index\controller;

use app\BaseController;
use app\index\model\Goods;
use app\index\model\GoodCategory;
use app\index\model\Member;
use think\facade\View;

class Index extends BaseController
{
    public function index(){
        // 自动登录的代码，判断是否有cookie，然后验证。
        $memberModel= new Member();
        $memberModel->autoLogin();

        $goodsModel= new Goods();
        $goodsData=$goodsModel->getPro();// 获取推荐商品
        // 获取新品，热卖，精品
        $newData=$goodsModel->getRec('is_new');
        $hotData=$goodsModel->getRec('is_hot');
        $bestData=$goodsModel->getRec('is_best');
        //楼层数据
        $cateGory= new GoodCategory();
        $floorData= $cateGory->getIndex();
        View::assign(array(
            'goodsData' => $goodsData,
            'newData' => $newData,
            'hotData' => $hotData,
            'bestData' => $bestData,
            'floorData'=>$floorData,
            '_show_nav'=> 1,
            '_page_title' => '首页',
            '_page_keywords' => '首页',
            '_page_description' => '首页',
        ));
        return View::fetch();
    }
}